import http from "@/utils/http"

//设置验证码的类型
export interface CaptchaData {
  image: string
  key: string
}
//声明登录功能参数的类型
export interface LoginParamData {
  username: string
  password: string
  captchaKey: string
  captchaCode: string
}
//声明查询的用户信息的类型
export interface UserData{
  name:string,
  avatarUrl?:string
}

export default {
  //发送ajax请求获取验证码
  getCaptchaCode() {
    return http.get<CaptchaData>('/admin/login/captcha')
  },
  //验证登录
  checkLogin(loginParam : LoginParamData){
    return http.post<string>('/admin/login',loginParam)
  },
  //获取当前登录的用户信息
  getUserInfo(){
    return http.get<UserData>('/admin/info')
  }
}